package com.hex.ds.hdrs.engine.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Package: com.hex.dataService.hdrs.scheduleEngine.interceptor
 * @ClassName WebConfig
 * @Description:拦截器配置类
 * @Author: <gc.zuo>
 * @Date 2021/6/8 11:18
 * @Version v1.0
 **/
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截请求
        String[] addPathPatterns = {"/api/cronTaskDef/add", "/api/jobDef/add"};
        //如果有多个拦截器，可以继续添加
        registry.addInterceptor(checkInterceptor()).addPathPatterns(addPathPatterns).excludePathPatterns();

    }

    @Bean
    public CheckInterceptor checkInterceptor() {
        return new CheckInterceptor();
    }
}